{% load brp_tags %}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>{{ book.title }}</title>
</head>
<body>
<h1>{{ book.title }}</h1>
<table>
    <tr>
        <th>Added</th>
        <td>{{ book.date_added }}</td>
    </tr>
    {% if book.date_started %}
        <tr>
            <th>Started reading</th>
            <td>{{ book.date_started }}</td>
        </tr>
    {% endif %}
    {% if book.date_finished %}
        <tr>
            <th>Finished reading</th>
            <td>{{ book.date_finished }}</td>
        </tr>
    {% endif %}
    {% if book.entries_read %}
        <tr>
            <th>Entries read</th>
            <td>{{ book.entries_read }} / {{ book.entries_total }} ({{ book.percent_entries_read|floatformat:2 }} %)</td>
        </tr>
        <tr>
            <th>Pages read</th>
            <td>{{ book.pages_read }} / {{ book.pages }} ({{ book.percent_pages_read|floatformat:2 }} %)</td>
        </tr>
    {% else %}
        <tr>
            <th>Entries</th>
            <td>{{ book.entries_total }}</td>
        </tr>
        <tr>
            <th>Pages</th>
            <td>{{ book.pages }}</td>
        </tr>
    {% endif %}
</table>
<form action="/brp/booksave/{{ book.id }}/" method="post">
    <input type="submit" value="Save"/>
    <table >
        <tr>
            <th colspan="{{ book.max_level }}">Title</th>
            <th>Page</th>
            <th>Read</th>
        </tr>
        {% for entry in book.entries.all %}
            <tr>
            {% for level in entry.level|get_range %}
                <td width="20px">{% if forloop.last %}╚{% endif %}</td>
            {% endfor %}
                <td colspan="{{ entry.inv_level }}">{{ entry.title }}</td>
                <td>{{ entry.page }}</td>
                <td><input type="checkbox" name="read" value="{{ entry.id }}" {% if entry.read %}checked{% endif %}>
                </td>
            </tr>
        {% endfor %}
    </table>
    <input type="submit" value="Save"/>
</form>
</body>
</html>